package com.cangchu.util;

import com.cangchu.ui.fragment.GoodsInfoFragment;
import com.cangchu.ui.fragment.newBaseFragment;

/**
 * Fragment 管理类，统一生产和管理碎片
 * 使用单例模式
 * Created by Administrator on 2016/11/8.
 */
public class FragmentFactory {
    public static final String TAG = "FragmentFactory";

    private static FragmentFactory sFragmentFactory;

    private newBaseFragment goodsInfoFragment;

    public static FragmentFactory getInstance() {
        if (sFragmentFactory == null) {
            synchronized (FragmentFactory.class) {
                if (sFragmentFactory == null) {
                    sFragmentFactory = new FragmentFactory();
                }
            }
        }
        return sFragmentFactory;
    }

    public newBaseFragment getFragment(int id) {
        switch (id) {
            default:
                return getGoodsInfoFragment();
        }
    }

    public newBaseFragment getGoodsInfoFragment() {

        if (goodsInfoFragment == null) {
            goodsInfoFragment = new GoodsInfoFragment();
        }
        return goodsInfoFragment;
    }
}
